import os
from datetime import timedelta

class Config:
    # 基本配置 - 紧急修复：硬编码SECRET_KEY
    SECRET_KEY = 'aqm-jwt-secret-1749456354171-rLD9xAdYFvBlNXa8vop3Um9zJ6l9V8qDSkhBbzVwVbCsHKvOaNsWiFmi34VpNlDD'
    # 备用方案：SECRET_KEY = os.getenv('SECRET_KEY', 'aqm-jwt-secret-1749456354171-rLD9xAdYFvBlNXa8vop3Um9zJ6l9V8qDSkhBbzVwVbCsHKvOaNsWiFmi34VpNlDD')
    
    # MongoDB配置
    MONGO_URI = os.getenv('MONGO_URI', 'mongodb://localhost:27017/')
    MONGO_DB = os.getenv('MONGO_DB', 'air_quality_db')
    
    # MySQL配置
    MYSQL_HOST = os.getenv('MYSQL_HOST', 'localhost')
    MYSQL_PORT = int(os.getenv('MYSQL_PORT', 3306))
    MYSQL_USER = os.getenv('MYSQL_USER', 'test2')
    MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', '123456')
    MYSQL_DB = os.getenv('MYSQL_DB', 'test2')
    
    # SQLAlchemy配置
    SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # JWT配置
    JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=7)
    
    # 日志配置 
    LOG_LEVEL = os.getenv('LOG_LEVEL', 'INFO')
    LOG_FILE = os.getenv('LOG_FILE', 'app.log')

    # 设备API密钥配置
    DEVICE_API_KEY = os.getenv('DEVICE_API_KEY', 'aqm-api-key-123')